/*     */ package com.yc.dao.station;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.PowerSupplyBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class PowerSupplyDAO
/*     */ {
/*  23 */   private static final Log log = LogFactory.getLog(PowerSupplyDAO.class);
/*  24 */   private SimpleDateFormat open = new SimpleDateFormat("yyyy-MM-dd");
/*  25 */   private SimpleDateFormat fresh = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*  26 */   private dbConnector dbcon = null;
/*     */ 
/*  28 */   private void dbConInit() { if (this.dbcon == null)
/*  29 */       this.dbcon = new dbConnector(); }
/*     */ 
/*     */   private void dbConClose()
/*     */   {
/*  33 */     if (this.dbcon != null)
/*  34 */       this.dbcon.closeAll();
/*  35 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getPowerSupplyList(Map condition)
/*     */   {
/*  40 */     ListContentsBFO bfo = new ListContentsBFO();
/*  41 */     int start = Integer.parseInt(condition.get("start").toString());
/*  42 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  43 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  44 */     ResultSet rs = null;
/*  45 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  48 */       dbConInit();
/*  49 */       String strSQL = " select count(id) from powersupply where btscode = '" + strBtscode + "' ";
/*  50 */       log.info(strSQL);
/*  51 */       rs = this.dbcon.execQuery(strSQL);
/*  52 */       if (rs.next()) {
/*  53 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  55 */       strSQL = " select * from powersupply where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  56 */       log.info(strSQL);
/*  57 */       rs = this.dbcon.execQuery(strSQL);
/*  58 */       while (rs.next()) {
/*  59 */         PowerSupplyBO bo = new PowerSupplyBO();
/*  60 */         bo.setId(rs.getString("id"));
/*  61 */         bo.setBtscode(rs.getString("btscode"));
/*  62 */         bo.setBtsname(rs.getString("btsname"));
/*  63 */         bo.setPowersupply(rs.getString("powersupply"));
/*  64 */         bo.setPstelephone(rs.getString("pstelephone"));
/*  65 */         bo.setContact(rs.getString("contact"));
/*  66 */         bo.setTelephone(rs.getString("telephone"));
/*  67 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  68 */         bo.setMemo(rs.getString("memo"));
/*  69 */         list.add(bo);
/*     */       }
/*  71 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  74 */       e.printStackTrace();
/*  75 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  78 */       dbConClose();
/*     */     }
/*  80 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean savePowerSupplyBO(PowerSupplyBO bo)
/*     */   {
/*  85 */     log.info("添加--基础供电归属---开始");
/*  86 */     boolean flag = true;
/*     */     try
/*     */     {
/*  89 */       dbConInit();
/*  90 */       StringBuffer sqlBuf = new StringBuffer();
/*  91 */       sqlBuf.append(" insert into powersupply ( btscode,  btsname, powersupply,  pstelephone,");
/*  92 */       sqlBuf.append(" contact, telephone, refreshtime,registtime, memo   ) values ( ");
/*  93 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/*  94 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/*  95 */       sqlBuf.append(" '" + bo.getPowersupply() + "' ,");
/*  96 */       sqlBuf.append(" '" + bo.getPstelephone() + "' ,");
/*  97 */       sqlBuf.append(" '" + bo.getContact() + "' ,");
/*  98 */       sqlBuf.append(" '" + bo.getTelephone() + "' ,");
/*  99 */       sqlBuf.append(" '" + this.fresh.format(new Date()) + "' ,");
/* 100 */       sqlBuf.append(" '" + this.open.format(new Date()) + "' ,");
/* 101 */       sqlBuf.append(" '" + bo.getMemo() + "' )");
/* 102 */       log.info(sqlBuf.toString());
/* 103 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 107 */       flag = false;
/* 108 */       e.printStackTrace();
/* 109 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 112 */       dbConClose();
/*     */     }
/* 114 */     log.info("添加--基础供电归属---结束");
/* 115 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updatePowerSupplyBO(PowerSupplyBO bo)
/*     */   {
/* 120 */     log.info("修改--基础供电归属---开始");
/* 121 */     boolean flag = true;
/*     */     try
/*     */     {
/* 124 */       dbConInit();
/* 125 */       StringBuffer sqlBuf = new StringBuffer();
/* 126 */       sqlBuf.append(" update  powersupply  set ");
/* 127 */       sqlBuf.append(" powersupply = '" + bo.getPowersupply() + "' ,");
/* 128 */       sqlBuf.append(" pstelephone = '" + bo.getPstelephone() + "' ,");
/* 129 */       sqlBuf.append(" contact = '" + bo.getContact() + "' ,");
/* 130 */       sqlBuf.append(" telephone = '" + bo.getTelephone() + "' ,");
/* 131 */       sqlBuf.append(" refreshtime = '" + this.fresh.format(new Date()) + "' ,");
/* 132 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' ");
/* 133 */       sqlBuf.append(" where id= '" + bo.getId() + "'");
/* 134 */       log.info(sqlBuf.toString());
/* 135 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 139 */       flag = false;
/* 140 */       e.printStackTrace();
/* 141 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 144 */       dbConClose();
/*     */     }
/* 146 */     log.info("修改--基础供电归属---结束");
/* 147 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deletePowerSupplyBO(String strID)
/*     */   {
/* 153 */     log.info("删除--基础供电归属---开始");
/* 154 */     boolean flag = true;
/*     */     try
/*     */     {
/* 157 */       dbConInit();
/* 158 */       StringBuffer sqlBuf = new StringBuffer();
/* 159 */       sqlBuf.append(" delete from   powersupply  ");
/* 160 */       sqlBuf.append(" where id= '" + strID + "'");
/* 161 */       log.info(sqlBuf.toString());
/* 162 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 166 */       flag = false;
/* 167 */       e.printStackTrace();
/* 168 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 171 */       dbConClose();
/*     */     }
/* 173 */     log.info("删除--基础供电归属---结束");
/* 174 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getPowerSupplyByBtsName(Map condition)
/*     */   {
/* 179 */     ListContentsBFO bfo = new ListContentsBFO();
/* 180 */     int start = Integer.parseInt(condition.get("start").toString());
/* 181 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 182 */     String strBtsName = condition.get("btsName").toString();
/* 183 */     ResultSet rs = null;
/* 184 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 187 */       dbConInit();
/* 188 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 189 */       Object objRegistEndTime = condition.get("registEndTime");
/*     */ 
/* 191 */       String strSQL = " select count(id) from powersupply where btsname like '%" + strBtsName + "%' ";
/* 192 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 193 */       log.info(strSQL);
/* 194 */       rs = this.dbcon.execQuery(strSQL);
/* 195 */       if (rs.next()) {
/* 196 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 198 */       strSQL = " select * from powersupply where btsname like '%" + strBtsName + "%' ";
/* 199 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 200 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 201 */       log.info(strSQL);
/* 202 */       rs = this.dbcon.execQuery(strSQL);
/* 203 */       while (rs.next()) {
/* 204 */         PowerSupplyBO bo = new PowerSupplyBO();
/* 205 */         bo.setId(rs.getString("id"));
/* 206 */         bo.setBtscode(rs.getString("btscode"));
/* 207 */         bo.setBtsname(rs.getString("btsname"));
/* 208 */         bo.setPowersupply(rs.getString("powersupply"));
/* 209 */         bo.setPstelephone(rs.getString("pstelephone"));
/* 210 */         bo.setContact(rs.getString("contact"));
/* 211 */         bo.setTelephone(rs.getString("telephone"));
/* 212 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 213 */         bo.setMemo(rs.getString("memo"));
/* 214 */         list.add(bo);
/*     */       }
/* 216 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 219 */       e.printStackTrace();
/* 220 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 223 */       dbConClose();
/*     */     }
/* 225 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName, String strRegistBeginTime, String strRegistEndTime)
/*     */   {
/* 231 */     ResultSet rs = null;
/* 232 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 235 */       dbConInit();
/* 236 */       String strSQL = " select * from powersupply where btsname like '%" + strBtsName + "%'  ";
/* 237 */       strSQL = FormateSQL.getFormateSQL(strRegistBeginTime, strRegistEndTime, strSQL);
/* 238 */       log.info(strSQL);
/* 239 */       rs = this.dbcon.execQuery(strSQL);
/* 240 */       while (rs.next()) {
/* 241 */         PowerSupplyBO bo = new PowerSupplyBO();
/* 242 */         bo.setId(rs.getString("id"));
/* 243 */         bo.setBtscode(rs.getString("btscode"));
/* 244 */         bo.setBtsname(rs.getString("btsname"));
/* 245 */         bo.setPowersupply(rs.getString("powersupply"));
/* 246 */         bo.setPstelephone(rs.getString("pstelephone"));
/* 247 */         bo.setContact(rs.getString("contact"));
/* 248 */         bo.setTelephone(rs.getString("telephone"));
/* 249 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 250 */         bo.setMemo(rs.getString("memo"));
/* 251 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 255 */       e.printStackTrace();
/* 256 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 259 */       dbConClose();
/*     */     }
/* 261 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.station.PowerSupplyDAO
 * JD-Core Version:    0.6.2
 */